package conf

import (
	"gopkg.in/yaml.v2"
	"io/ioutil"
)

var Global_Conf *  Config

type Config struct {
	Address string `yaml:"address"`
	Port string `yaml:"port"`

	GinMaxConnects int32 `yaml:"ginMaxConnects"`

	WKListenAddr string `yaml:"wkListenAddr"`
	WKListenPort string `yaml:"wkListenPort"`
	MaxReceiveMsgCount int32 `yaml:"maxReceiveMsgCount"`

	MysqlAddress string `yaml:"mysqladdress"`
	MysqlPort string `yaml:"mysqlport"`
	MysqlUser string `yaml:"mysqluser"`
	MysqlPasswd string `yaml:"mysqlpasswd"`

	Authorization string `yaml:"authorization"`
}

//LoadConfig ..加载配置文件
func LoadConfig(path string) (* Config,error){
	buf,err := ioutil.ReadFile(path)
	if err!=nil{
		return nil,err
	}
	Global_Conf = new(Config)
	err = yaml.Unmarshal(buf,Global_Conf)
	if err!=nil{
		return nil,err
	}
	return Global_Conf,nil
}